package com.xwj.service.impl;

import com.xwj.service.MessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import java.util.UUID;

/**
 * 定义消息的推送通道
 * @author xwj
 * @date 2020/4/14
 */
@EnableBinding(Source.class)
public class RabbitMqMessageProviderImpl implements MessageProvider {
    /**
     * 消息发送通道
     */
    @Autowired
    private MessageChannel output;
    @Override
    public String send() {
        String s = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(s).build());
        return s;
    }
}
